package thu.cs.segroup.agent.behaviour;

import thu.cs.segroup.agent.Runner;
import jade.core.Agent;
import jade.core.Location;
import jade.core.behaviours.OneShotBehaviour;

public class RunnerMigrateBehav extends OneShotBehaviour {

	private Location location;
	
	public RunnerMigrateBehav(Agent agent, Location location) {
		super(agent);
		this.location = location;
	}
	
	@Override
	public void action() {
		// TODO
		// myAgent.doMove(location);
		if (location.equals(myAgent.here())) {
			myAgent.addBehaviour(new RunnerConfigTestBehav(myAgent));
		} else {
			System.out.println("Migrate LOG: " + myAgent.getLocalName() + " will migrate to " + location.getName());
			myAgent.doMove(location);
		}
	}

}
